//
//  ZJMessageInvigilateViewController.m
//  ZJControlsClass
//
//  Created by wandoufo on 2024/12/6.
//

#import "ZJMessageInvigilateViewController.h"
#import <Masonry/Masonry.h>

@interface ZJMessageInvigilateViewController ()

@property (nonatomic, strong) UILabel *titleLabel;      // 标题标签
@property (nonatomic, strong) UILabel *greetingLabel;   // 问候语标签
@property (nonatomic, strong) UILabel *greetingLabel1;   // 问候语标签
@property (nonatomic, strong) UIView *contentView;      // 内容容器视图

@end

@implementation ZJMessageInvigilateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"监考消息详情";
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setupUI];
    
//    [self setData];
}

- (void)setupUI {
    // 创建标题
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.text =  self.model.otherData[@"businessName"];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
    titleLabel.textColor = [UIColor colorWithHexString:@"#181818"];
    [self.view addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
//    self.titleLabel.text =
//    self.model.otherData.
    
    // 创建问候语
    UILabel *greetingLabel = [[UILabel alloc] init];
    greetingLabel.text =[NSString stringWithFormat: @"%@, 你好:",self.model.otherData[@"name"]];
//    greetingLabel.numberOfLines = 0;
    titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightBold];
    titleLabel.textColor = [UIColor colorWithHexString:@"#181818"];
//    greetingLabel.font = [UIFont systemFontOfSize:16];
    [self.view addSubview:greetingLabel];
    
    UILabel *greetingLabel1 = [[UILabel alloc] init];
    greetingLabel1.text =[NSString stringWithFormat: @"请你担任\"%@\"的监考老师",self.model.otherData[@"subject"]];// @"请你担任\"XXXX考试名\"的监考老师";
//    greetingLabel1.numberOfLines = 0;
    greetingLabel1.font = [UIFont systemFontOfSize:15];
    [self.view addSubview:greetingLabel1];
    
    
    self.greetingLabel = greetingLabel;
    self.greetingLabel1 = greetingLabel1;
    // 创建内容容器
    UIView *contentView = [[UIView alloc] init];
    [self.view addSubview:contentView];
    self.contentView = contentView;
    
    // 设置约束
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(20 + StatusBarHeight);
        make.left.right.equalTo(self.view);
//        make.height.mas_equalTo(30);
    }];
    
    [greetingLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleLabel.mas_bottom).offset(30);
        make.left.equalTo(self.view).offset(20);
        make.right.equalTo(self.view).offset(-20);
    }];
    
    [greetingLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(greetingLabel.mas_bottom).offset(6);
        make.left.equalTo(self.view).offset(20);
        make.right.equalTo(self.view).offset(-20);
//        make.bottom.equalTo(self.view).offset(-20);
    }];
    
    [self setupInfoItems];
}

- (void)setData {
//    businessName = "长期人员通行证";
//    checkInTime = "2024-12-17 17:20:00";
//    location = "101教室";
//    name = "超级管理员";
//    startTime = "2024-12-17 17:50:00-23:00:00";
//    subject = "科目1";

    
}

- (void)setupInfoItems {
    NSArray *titles = @[@"考试时间", @"考试地点", @"签到开始时间"];
    NSArray *contents = @[self.model.otherData[@"startTime"],
                          self.model.otherData[@"location"],
                          self.model.otherData[@"checkInTime"]];
    
    UIView *lastView = nil;
    
    for (NSInteger i = 0; i < titles.count; i++) {
        UIView *itemView = [self createInfoItemWithTitle:titles[i] content:contents[i]];
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = [UIColor colorWithHexString:@"#D7D8D9"];
        [self.contentView addSubview:itemView];
        [self.contentView addSubview:lineView];
        
        [itemView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.view);
            if (!lastView) {
                make.top.equalTo(self.greetingLabel1.mas_bottom).offset(16);
            } else {
                make.top.equalTo(lastView.mas_bottom);
            }
            make.height.mas_equalTo(59);
//            if (i = 0) {
//                m
//            }
        }];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(12);
            make.right.equalTo(self.view).offset(-12);
            make.height.mas_equalTo(0.5);
            make.bottom.equalTo(itemView.mas_bottom);
        }];
        
        lastView = itemView;
    }
}

- (UIView *)createInfoItemWithTitle:(NSString *)title content:(NSString *)content {
    UIView *itemView = [[UIView alloc] init];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.text = title;
    titleLabel.textColor = [UIColor colorWithHexString:@"999999"];
    titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
    [itemView addSubview:titleLabel];
    
    UILabel *contentLabel = [[UILabel alloc] init];
    contentLabel.text = content;
    contentLabel.textColor = [UIColor colorWithHexString:@"#191D20"];
    contentLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
    [itemView addSubview:contentLabel];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(itemView).offset(20);
        make.centerY.equalTo(itemView);
    }];
    
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(itemView).offset(-20);
        make.centerY.equalTo(itemView);
    }];
    
    return itemView;
}

@end
